﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed

#pragma once

#include "GnufBase.h"
#include "GnufINotificationCenterEvent.h"
#include "GnufINotificationCenterEventHandler.h"
#include "GnufINotificationCenterEventArgs.h"

namespace {
    class NotificationCenterEvent;
}
namespace gnuf {
/*                              Notification
                                Center 
                                 _ _ _ _ _ _ 
 ___________    Input Channel   |           |       +-----------+
|           |<<<<<<<<<<<<<<<<<<<|<<<<<<<<<<<|<<<<<<<|           |         ____
| New       |                   |           |       | Product   |        /    \
| UI        |                   |           |       | (GAP,     |<----->( Gcmp )
| Framework |                   |           |       |  BIMMake, |        \____/
|___________|>>>>>>>>>>>>>>>>>>>|>>>>>>>>>>>|>>>>>>>|  ...)     |
                Output Channel  |_ _ _ _ _ _|       +-----------+
*/

    enum class ENotificationChannel : std::uint8_t {
        eInput,
        eOutput,
    };
    
    class GNUF_BASE_EXPORT NotificationCenter final
    {
    private:
        NotificationCenter();
        ~NotificationCenter();

    public:
        static NotificationCenter * get();

        void   subscribe(const ENotificationChannel, INotificationCenterEventHandler *);
        void unsubscribe(const ENotificationChannel, INotificationCenterEventHandler *);

        void send(const ENotificationChannel, INotificationCenterEventArgs *);

    private:
        NotificationCenterEvent * eventOf(const ENotificationChannel);
        gcmp::OwnerPtr< NotificationCenterEvent > m_input, m_output;
    };
}

